package com.chenxin.wms.controller;

import com.chenxin.common.annotation.Log;
import com.chenxin.common.core.controller.BaseController;
import com.chenxin.common.core.page.TableDataInfo;
import com.chenxin.common.enums.BusinessType;
import com.chenxin.common.utils.poi.ExcelUtil;
import com.chenxin.wms.domain.WarehouseEntity;
import com.chenxin.wms.domain.vo.WarehouseVO;
import com.chenxin.wms.service.IWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 仓库资料Controller
 *
 * @author gry
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/wms/warehouse")
public class WarehouseController extends BaseController {
    @Autowired
    private IWarehouseService warehouseService;

    /**
     * 查询仓库资料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:warehouse:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarehouseEntity warehouseEntity) {
        startPage();
        List<WarehouseVO> list = warehouseService.selectWarehouseList(warehouseEntity);
        return getDataTable(list);
    }

    /**
     * 导出仓库资料列表
     */
    @PreAuthorize("@ss.hasPermi('wms:warehouse:export')")
    @Log(title = "仓库资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarehouseEntity warehouseEntity) {
        List<WarehouseVO> list = warehouseService.selectWarehouseList(warehouseEntity);
        ExcelUtil<WarehouseVO> util = new ExcelUtil<>(WarehouseVO.class);
        util.exportExcel(response, list, "仓库资料数据");
    }
}
